/*
 * @Description:
 * @Autor: zzzzzed
 * @Date: 2025-01-26 14:38:09
 * @LastEditors: zzzzzed
 * @LastEditTime: 2025-01-26 14:47:43
 */

import { LRUCache, LRUKey,LRUObj } from "./lru/LRUCache";


class MyObj extends LRUObj {
    public key: LRUKey = "";

    constructor(key: LRUKey) {
        super();
        this.key = key;
    }

    public destroy(): void {
        console.log("====> onDelete ");
    }
}

export class TestLRU {
    public static test() {
        let lru = new LRUCache(3);
        lru.set(2, new MyObj(2));
        lru.set(1, new MyObj(1));
        
        lru.dump();
        lru.set(2, new MyObj(1));
        lru.dump();
        
        // lru.deleteAll();
        // lru.dump();
        console.log("get 1: ", lru.get(1));
        lru.dump();
        console.log("get 3: ", lru.get(3));
        lru.dump();

        lru.set(3, new MyObj(3));
        lru.dump();

        lru.set(4, new MyObj(4));
        lru.dump();
        

    }
}